﻿
@{
    Layout = null;
}

<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>后台登录--JOKER美容院系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="stylesheet" href="~/css/font.css">
    <link rel="stylesheet" href="~/css/login.css">
    <link rel="stylesheet" href="~/css/xadmin.css">
    <script type="text/javascript" src="~/Scripts/jquery.min.js"></script>
    <script src="~/lib/layui/layui.js" charset="utf-8"></script>

    <!--[if lt IE 9]>
      <script src="~/Scripts/html5.min.js"></script>
      <script src="~/Scripts/respond.min.js"></script>
    <![endif]-->
</head>
<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message">美容院——管理登录</div>
        <div id="darkbannerwrap"></div>

        <form method="post" class="layui-form">
            <input name="UserName" placeholder="用户名" value="admin" type="text" lay-verify="required" class="layui-input">
            <hr class="hr15">
            <input name="Password" lay-verify="required" value="admin1" placeholder="密码" type="password" class="layui-input">
            <hr class="hr15">

            <input name="ImgCode" lay-verify="required" placeholder="验证码" type="text" class="layui-input" style="width:180px;" />

            <div style="float:right;margin:-50px auto;padding-right:20px">
                <img style="border-radius:7px; cursor:pointer" id="ReloadImg" alt="验证码图片" height="50" onclick="Refresh(this)" title="点击刷新" src="/User/VerifyCode" />
            </div>
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20">
        </form>
    </div>

    <script>
        $(function () {
            layui.use('form', function () {
                var form = layui.form;
                var layer = layui.layer;

                //监听提交
                form.on('submit(login)', function (data) {

                    layer.load(3);
                    $.ajax({
                        url: '/User/Login',
                        type: 'post',
                        data: data.field,
                        dataType: 'json',
                        success: function (data) {
                            //if (data == "OK") {
                            //    layer.alert("登录成功", {
                            //        icon: 6
                            //    }, function () {
                            //        window.location.href = "/Home/Index";
                            //    });
                            //} else if (data == "WrongCode") {
                            //    layer.alert("验证码错误", { icon: 2 });
                            //    RefreshImg();
                            //} else {
                            //    layer.alert("登录失败", { icon: 2 });
                            //    RefreshImg();
                            //}


                            if (data.ResultType == 1) {
                                layer.alert(data.Msg, {
                                    icon: 6
                                }, function () {
                                    window.top.location.href = "/Home/Index";
                                });
                            } else if (data.ResultType == 2) {
                                layer.alert(data.Msg, { icon: 2 });
                                RefreshImg();
                            } else {
                                layer.alert(data.Msg, { icon: 2 });
                                RefreshImg();
                            }
                        },
                        error: function (err) {
                            layer.alert("登录失败", {
                                icon: 2
                            });
                            RefreshImg();
                        }
                    });
                    layer.closeAll("loading");
                    return false;
                });
            });
        });

        // 点击验证码，刷新验证码
        function Refresh(obj) {
            $(obj).attr("src", "/User/VerifyCode?RndNumber=" + Math.random());
        }
        // 登录失败，刷新验证码
        function RefreshImg() {
            $("#ReloadImg").attr("src", "/User/VerifyCode?RndNumber=" + Math.random());

        }
    </script>

</body>
</html>
